package com.lerays.spider.sougou.server;

import org.lionsoul.websnail.json.JSONArray;

/**
 * server client data transfer protocol.
 * 
 * @author chenxin<chenxin619315@gmail.com>
 */
public class CommandExecutor 
{
	//------------------------spider control------------------------
	/**
	 * spider pause command 
	 */
	public static final int SPIDER_PAUSE_CMD = 1;
	
	/**
	 * spider resume from the pause command 
	 */
	public static final int SPIDER_RESUME_CMD = 2;
	
	/**
	 * spider running status command 
	 * the result could be RUNNING | PAUSED
	 */
	public static final int SPIDER_RUNNING_STATUS = 3;
	
	
	//-----------------------resource exchange----------------------
	/**
	 * load the source command.
	 * the spider will reload the source from the remote database server 
	 */
	public static final int LOAD_SOURCE_CMD = 11;
	
	/**
	 * start the source analysis command.
	 * this command will force the spider to lead all the source
	 * to the spider#todoHandler.
	 */
	public static final int SOURCE_ANALYSIS_CMD = 12;
	
	/**
	 * wechat history page session reset command.
	 * reset the key or the uin of the spider. 
	 */
	public static final int SESSION_SETTING_CMD = 13;
	
	/**
	 * todo size return command.
	 * get the current todo list size. 
	 */
	public static final int SPIDER_TODO_SIZE = 14;
	
	
	/**
	 * {
	 * 	"cmd": [
	 * 		{"name": command-code, "args": {}}
	 * 	]	
	 * }
	 * 
	 * {
	 * 	"ret": [
	 * 		{"ret": {}}
	 *  ]
	 * }
	 */
	
	//private SpiderServer spiderServer = null;

	public CommandExecutor( SpiderServer spiderServer )
	{
		//this.spiderServer = spiderServer;
	}
	
	/**
	 * parse and execute the specifield command and get the
	 * 	returning result
	 * 
	 * @param	cmds
	 * @return	String
	 */
	public String execute( JSONArray cmds )
	{
		//spiderServer.getSpider().setKey(key);
		
		return "{\"ret\":[{\"ret\": \"Ok\"}]}";
	}
}
